package cn.sc.allinpay.allfavour.business.setconfig;

import android.os.Bundle;
import android.support.v7.widget.AppCompatEditText;
import android.support.v7.widget.AppCompatTextView;
import android.view.View;

import butterknife.BindView;
import butterknife.OnClick;
import cn.sc.allinpay.allfavour.R;
import cn.sc.allinpay.allfavour.base.activity.BaseActivity;

/**
 * 参数设置
 */
public class SetConfigActivity extends BaseActivity<SetConfigContract.View, SetConfigContract.Presenter> implements SetConfigContract.View {

    @BindView(R.id.etMerName)
    AppCompatEditText etMerName;
    @BindView(R.id.etBrchNo)
    AppCompatEditText etBrchNo;
    @BindView(R.id.etTerId)
    AppCompatEditText etTerId;
    @BindView(R.id.etAllinIp)
    AppCompatEditText etAllinIp;
    @BindView(R.id.etAllinPort)
    AppCompatEditText etAllinPort;
    @BindView(R.id.etBrchKey)
    AppCompatEditText etBrchKey;
    @BindView(R.id.etTempKey1)
    AppCompatEditText etTempKey1;
    @BindView(R.id.etTempKey2)
    AppCompatEditText etTempKey2;
    @BindView(R.id.etSpOrg)
    AppCompatEditText etSpOrg;
    @BindView(R.id.etSpUserName)
    AppCompatEditText etSpUserName;
    @BindView(R.id.etSpPwd)
    AppCompatEditText etSpPwd;

    @Override
    protected int layoutId() {
        return R.layout.activity_set_config;
    }

    @Override
    protected void layoutTitle(View top, AppCompatTextView left, AppCompatTextView title, AppCompatTextView right) {
        title.setText("参数设置");
        left.setVisibility(View.GONE);
    }

    @Override
    protected SetConfigContract.Presenter bindPresenter() {
        return new SetConfigPresenter();
    }

    @Override
    protected void layoutContent(Bundle savedInstanceState) {
        etAllinPort.setFocusable(false);
        etAllinPort.setFocusableInTouchMode(false);
        etTempKey1.setFocusable(false);
        etTempKey1.setFocusableInTouchMode(false);
        etTempKey2.setFocusable(false);
        etTempKey2.setFocusableInTouchMode(false);
    }

    @OnClick(R.id.btnSave)
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.btnSave:
                presenter.save();
                break;
        }
    }

    @Override
    public void showMerName(String data) {
        etMerName.setText(data);
    }

    @Override
    public void showBrchNo(String data) {
        etBrchNo.setText(data);
    }

    @Override
    public void showTerId(String data) {
        etTerId.setText(data);
    }

    @Override
    public void showAllinIp(String data) {
        etAllinIp.setText(data);
    }

    @Override
    public void showAllinPort(String data) {
        etAllinPort.setText(data);
    }

    @Override
    public void showBrchKey(String data) {
        etBrchKey.setText(data);
    }

    @Override
    public void showTempKey1(String data) {
        etTempKey1.setText(data);
    }

    @Override
    public void showTempKey2(String data) {
        etTempKey2.setText(data);
    }

    @Override
    public void showSpOrgNo(String data) {
        etSpOrg.setText(data);
    }

    @Override
    public void showSpUserName(String data) {
        etSpUserName.setText(data);
    }

    @Override
    public void showSpPwd(String data) {
        etSpPwd.setText(data);
    }

    @Override
    public String getMerName() {
        return etMerName.getText().toString().trim();
    }

    @Override
    public String getBrchNo() {
        return etBrchNo.getText().toString().trim();
    }

    @Override
    public String getTerId() {
        return etTerId.getText().toString().trim();
    }

    @Override
    public String getAllinIp() {
        return etAllinIp.getText().toString().trim();
    }

    @Override
    public String getAllinPort() {
        return etAllinPort.getText().toString().trim();
    }

    @Override
    public String getBrchKey() {
        return etBrchKey.getText().toString().trim();
    }

    @Override
    public String getTempKey1() {
        return etTempKey1.getText().toString().trim();
    }

    @Override
    public String getTempKey2() {
        return etTempKey2.getText().toString().trim();
    }

    @Override
    public String getSpOrgNo() {
        return etSpOrg.getText().toString().trim();
    }

    @Override
    public String getSpUserName() {
        return etSpUserName.getText().toString().trim();
    }

    @Override
    public String getSpPwd() {
        return etSpPwd.getText().toString().trim();
    }
}
